from os import write
import random
import urllib3
import json
import time
import csv

if __name__ == "__main__":
    http = urllib3.PoolManager()
    f = open("id_list.csv", 'w')
    w = csv.writer(f)
    for i in range(50):
        id_list = []
        r= http.request('GET', 'https://ihotel.meituan.com/hbsearch/HotelSearch?utm_medium=pc&version_name=999.9&cateId=20&attr_28=129&uuid=30FF356A1A6CCE82771232FE955CAA2A53C85C7C26AA51977E961DAE3985EFA7%401607073688983&cityId=45&offset={}&limit=20&startDay=20201204&endDay=20201204&q=&sort=defaults&X-FOR-WITH=YsHA9qNYNb5O4z9Z7JO5YbMO7pxf5k7kzPN9oFdJ9wfB9OSz2ADtsPQrtHQrU2jRl8nrblx7XEwwwQbuH%2Ba%2BkRgu6mRc7KNXHLdwz4x65ulyaPm5zJw8xfa2UORnne02KWwZ2TKadne45YZpOo%2Bh0JPX%2BuIfrviP4wqQPZ6Q0O4QjCyGnc5BCe75iig%2BAEkF2%2FS31lN9YjWWB3WvXc%2BhHg%3D%3D'.format(i*20))
        id_json = json.loads(r.data.decode('utf-8'))
        # print(id_json)
        for item in id_json["ct_pois"]:
            id_list.append(item["poiid"])
        print(id_list)
        w.writerow(id_list)
        
    f.close()
    
    